import useUserStore from '@/store/modules/user'
import { pages, globalStyle } from '@/pages.json'

// 获取路径标题
export function getTitle() {
  const page = getCurrentPages()
	const currentPage = page[page.length - 1]
	const path = `${currentPage.route}`
	const menu = useUserStore().pages
	const menuFilter = menu.filter(item => item.page === path)
	
	if (menuFilter.length > 0) {
		return menuFilter[0].meta.title
	} else {
		const pageFilter = pages.filter(item => item.path === path)
		return pageFilter[0].length > 0 ? pageFilter[0].style.navigationBarTitleText : globalStyle.navigationBarTitleText
	}
}
